package com.avalon.shop;

import com.avalon.core.context.Context;
import com.avalon.core.util.ObjectUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopContext {
    private Context context;

    public ShopContext(Context context) {
        this.context = context;
    }


    public void setBackToken(String token) {
        context.setGlobalData("backToken", token);
    }

    public String getBackToken() {
        if (ObjectUtils.isNull(context.getGlobalData("backToken"))) {
            log.error("backToken is null");
            return null;
        }
        return context.getGlobalData("backToken").toString();
    }

    public boolean isBackLogin() {
        return context.getGlobalData("backToken") != null;
    }
}
